package base.day18.exception;

import java.util.Scanner;

public class exception4 {
    public static void main(String[] args) {
        Student student=new Student();
        Scanner sc=new Scanner(System.in);
        while (true){
            System.out.println("请输入年龄：");
            String strage=sc.next();
            try {
                int age=Integer.parseInt(strage);
                student.setAge(age);
                System.out.println("输入成功");
                break;
            }
            catch(NumberFormatException err2){
                System.out.println("请输入数字");
                continue;
            }
            catch(java.lang.Exception err){
                System.out.println("符合范围的数字");
                continue;
            }
        }
    }
}
